package com.example.demo_job.mapper;


import com.example.demo_job.entity.Recruit;
import com.example.demo_job.entity.RecruitSeeker;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RecruitMapper {

    @Select("SELECT * FROM Recruit WHERE sid=#{sid} AND pid=#{pid}")
    Recruit findBySidPid(int sid, int pid);

    @Insert("INSERT INTO Recruit(sid, pid,flag) values (#{sid}, #{pid},0)")
    void add(int sid, int pid);

    @Delete("DELETE FROM Recruit WHERE sid=#{sid} AND pid=#{pid}")
    void delete(int sid, int pid);

    @Select("select seeker.sinfo,seeker.sphone,recruit.sid,susername,sname,sedu,sgender,sphone,recruit.pid,position.cid,pname,salary,hot,paddress,flag from position,recruit,seeker where position.pid=recruit.pid and seeker.sid=recruit.sid and recruit.pid=#{pid} order by sedu desc")
    List<RecruitSeeker> QueryRecruit(int pid);


    @Update("UPDATE recruit SET flag =#{flag} WHERE sid = #{sid} and pid = #{pid}")
    void UpdateFlag(int sid, int pid,boolean flag);

    @Select("select recruit.flag,seeker.sinfo,seeker.sphone,recruit.sid,susername,sname,sedu,sgender,sphone,recruit.pid,position.cid,pname,salary,hot,paddress from position,recruit,seeker where position.pid=recruit.pid and seeker.sid=recruit.sid and recruit.pid =#{pid} and sedu>=#{sedu} order by sedu desc")
    List<RecruitSeeker> QueryRecruitByEdu(int pid, int sedu);


    @Select("select enumber from position where pid = #{pid}")
    int findenumberBypid(int pid);

    @Select("select anumber from position where pid = #{pid}")
    int findanumberBypid(int pid);

    @Update("update position Set anumber=anumber+#{i} where pid = #{pid}")
    void updatePositionNumBypid(int pid, int i);
}
